import request from 'umi-request';

export default {
  namespace: 'list',

  state: [
 
  ],

  reducers: {
    update(_, { payload }) {
      const { list } = payload;
      return list;
    },

    deleteLb(state, { payload }) {
      const { key: targetId } = payload;

      return state.filter((e) => e.key !== targetId);
    },

    addEmployee(state, { payload }) {
        const { user } = payload;
  
        return state.concat(user);
      },
  },

  effects: {
    *getAll(_, { call, put }) {
        const response = yield call(request.get, '/api/list');
  
        yield put({
          type: 'update',
          payload: {
            list: response,
          },
        });
      },
  },
};
